package com.jiuyi.controller;

import com.jiuyi.common.R;
import com.jiuyi.entity.Category;
import com.jiuyi.mapper.CategoryMapper;
import com.jiuyi.service.Impl.CategoryServiceImpl;
import com.jiuyi.vo.AdminSelectCategoryListVo;
import com.jiuyi.vo.AdminSelectCategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * DATA: 2022/10/19
 * Author: 晨夕
 */
@RestController
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryServiceImpl categoryServiceImpl;

    /**
     * 添加分类
     */
    @PostMapping()
    public R addCategory(@RequestBody Category category){
        return categoryServiceImpl.addCategory(category);
    }
    /**
     * 查询分类
     */
    @GetMapping("/page")
    public R<AdminSelectCategoryVo> selectCategory(int page, int pageSize){
        return categoryServiceImpl.selectCategory(page,pageSize);
    }
    /**
     * 修改分类
     */
    @PutMapping
    public R updateCategory(@RequestBody Category category){
        return categoryServiceImpl.updateCategory(category);
    }
    /**
     * 删除分类
     */
    @DeleteMapping
    public R deleteCategory(Long ids){
        return categoryServiceImpl.deleteCategory(ids);
    }
    /**
     * 查询分类列表
     */
    @GetMapping("/list")
    public R<AdminSelectCategoryListVo> selectCategoryList(){
        return categoryServiceImpl.selectCategoryList();
    }

}
